package com.wjjun.base.ui.base;

import android.databinding.ObservableField;

import com.qingmi.farmer.R;
import com.wjjun.basemvpvm.viewmodel.BaseViewModel;

/**
 * 最好不要直接设置属性
 * author Wjjun
 * Created 2018/3/14.
 */

public class BaseActivityViewModel extends BaseViewModel {

    //是否显示appBar
    public final ObservableField<Boolean> isShowAppBar = new ObservableField<>(true);

    //activity的标题
    public final ObservableField<String> title = new ObservableField<>();

    //是否显示左边的按钮
    public final ObservableField<Boolean> isShowLeftBtn = new ObservableField<>(true);

    //左边按钮的资源id
    public final ObservableField<Integer> leftResId = new ObservableField<>(R.drawable.ic_back);

    //右边第一个按钮的资源id
    public final ObservableField<Integer> rightFirstBtnResId = new ObservableField<>(0);

    //右边第二个按钮的资源id
    public final ObservableField<Integer> rightSecondBtnResId = new ObservableField<>(0);

    //右边第三个按钮的资源id
    public final ObservableField<Integer> rightThreeBtnResId = new ObservableField<>(0);

    //右边textView的文本
    public final ObservableField<String> rightText = new ObservableField<>();

    public final ObservableField<Boolean> isRightTextCheck = new ObservableField<>(false);

    //是否显示appBar
    public void setShowAppBar(boolean isShow) {
        isShowAppBar.set(isShow);
    }

    public void setTitle(String title) {
        this.title.set(title);
    }

    public void setShowLeftBtn(boolean isShow) {
        this.isShowLeftBtn.set(isShow);
    }

    public void setLeftResId(int resId) {
        this.leftResId.set(resId);
    }

    public void addRightBtn(int resId) {
        if (rightFirstBtnResId.get() == 0) {
            rightFirstBtnResId.set(resId);
        } else if (rightThreeBtnResId.get() == 0) {
            rightSecondBtnResId.set(resId);
        } else {
            rightThreeBtnResId.set(resId);
        }
    }

    public void addRightText(String text) {
        this.rightText.set(text);
    }

    public void setRightTextCheck(boolean check){
        this.isRightTextCheck.set(check);
    }

}
